package webEquipeRechercheGwt.client.handler.creation.entity;

import webEquipeRechercheGwt.client.callback.creation.CallBackSoftwareCreationAndModification;
import webEquipeRechercheGwt.client.entityCreationPanel.SoftwareCreationPanel;
import webEquipeRechercheGwt.client.services.SoftwareService;
import webEquipeRechercheGwt.client.services.SoftwareServiceAsync;
import webEquipeRechercheGwt.client.structure.DataShowingPanel;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class ClickHandlerSoftwareCreation  implements ClickHandler {

	SoftwareCreationPanel creationPanel;
	DataShowingPanel mainPanel;
	
	public ClickHandlerSoftwareCreation(SoftwareCreationPanel creationPanel,DataShowingPanel mainPanel) {
		super();
		this.creationPanel = creationPanel;
		this.mainPanel = mainPanel;
	}

	@Override
	public void onClick(ClickEvent event) {
		SoftwareServiceAsync service = GWT.create(SoftwareService.class);
		AsyncCallback<Boolean> callback = new CallBackSoftwareCreationAndModification(mainPanel);
		service.createSoftware(creationPanel.getMirror(), callback);
	}

}
